<template>
  <div>
    <el-tabs type="border-card">
      <el-tab-pane label="柜机配置">
        <div>
          <r-search ref="search" :searchData="searchData" :searchForm="searchForm" :searchHandle="searchHandle"
            :searchRules="searchRules" :inline="false" labelWidth="180px" labelPosition="right" />
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  name: "equipment_configuration",
  data() {
    return {
      searchData: {
        outOfStockJz: '',
        outOfStockJj: '',
        weightError: '',
        icLowestMoney: '',
        priceLowestMoney: ''
      },
      searchForm: [
        // { type: "input",label:'计重商品缺货阀值(g)', placeholder: "名称", prop: "outOfStockJz", width: 200 },
        // { type: "input",label:'计件商品缺货阀值(件)', placeholder: "账号", prop: "outOfStockJj", width: 200 },
        // { type: "input",label:'串货误差值(g)', placeholder: "请输入项目名称", prop: "weightError", width: 200 },
        { type: "input", label: 'IC卡最低开门金额(元)', placeholder: "请输入客服热线", prop: "icLowestMoney", width: 200 },
        { type: "input", label: '余额最低开门金额(元)', placeholder: "请输入客服热线", prop: "priceLowestMoney", width: 200 },
      ],
      searchHandle: [
        { type: 'primary', label: '', handle: e => this.elFormSubmit(), }
      ],
      searchRules: {
        outOfStockJz: [
          { required: true, message: '请输入', trigger: 'blur' },
        ],
        outOfStockJj: [
          { required: true, message: '请输入', trigger: 'blur' },
        ],
        weightError: [
          { required: true, message: '请输入', trigger: 'blur' },
        ],
        icLowestMoney: [
          { required: true, message: '请输入', trigger: 'blur' },
        ],
        priceLowestMoney: [
          { required: true, message: '请输入', trigger: 'blur' },
        ]
      }
    }
  },
  mounted() {
    this.getData();
  },
  methods: {
    async getData() {
      var res = await this.apis.getBaseInfo({});
      this.searchData = res.data || {};
    },
    elFormSubmit() {
      this.$refs.search.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.submit();
        }
      })
    },
    async submit() {
      var res = await this.apis.updateBaseInfo({
        outOfStockJj: this.searchData.outOfStockJj,
        outOfStockJz: this.searchData.outOfStockJz,
        priceLowestMoney: this.searchData.priceLowestMoney,
        weightError: this.searchData.weightError,
        icLowestMoney: this.searchData.icLowestMoney,
      });

      this.$message({
        message: '操作成功',
        type: 'success'
      });
    }
  }
}
</script>

<style scoped lang="scss">
</style>
